<template>
  <el-table
    ref="multipleTable"
    :data="myarr"
    style="width: 100%"
    @selection-change="handleSelectionChange">
    <el-table-column
      type="selection"
      width="55">
    </el-table-column>
    <el-table-column
      label="订单编号"
      color="black">
      <template slot-scope="scope">{{ scope.row.order }}</template>
    </el-table-column>
    <el-table-column
      prop="classification"
      label="订单分类">
    </el-table-column>
    <el-table-column
      label="标题">
      <template slot-scope="scope">
       <span>{{ typeObj[scope.row.title] }}</span>
        </template>
    </el-table-column>
    <el-table-column
      label="订单金额">
      <template slot-scope="scope">{{ scope.row.money }}</template>
    </el-table-column>
    <el-table-column
      prop="state"
      label="订单状态">
    </el-table-column>
    <el-table-column
      label="下单时间">
      <template slot-scope="scope">{{ scope.row.time }}</template>
    </el-table-column>
  </el-table>
</template>

<script>
import {bachtDeleeApi} from '../../../api/financialApi'
import eventBus from '../../../utls/eventBus'
export default {
    props:['myarr'],
    data() {
      return {
        typeObj:{
          0:'幼儿英语课程',
          1:'幼儿语文课程',
          2:'幼儿数学课程',
        },
        // tableData: [{
        //   order:'2019030102369669',
        //   classification:'课程订单',
        //   title:0,
        //   money:'￥2366.00',
        //   state:'待支付',
        //   time:'2019-01-25 10:55'
        // }, ],
        multipleSelection: [],
      }
    },
    mounted() {
      eventBus.$on('batchtranfer',this.bathDeletefun)
    },
    methods: {
      bathDeletefun(){//批量删除
        console.log('批量')
        var idArr=this.multipleSelection.map(item=>item.id)
        var ids = idArr.join(',')
        bachtDeleeApi({ids:ids}).then(res=>{
          console.log(res)
          if(res.code == 200){
            this.$emit('resetTable')
          }
        })
      },
      toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      }
    }
  }
</script>

<style lang="less">
.cell{
    text-align: center;
}
</style>